Skip to content

Redraw the macOS window only when something changed, and cache scaled pictures - #898

Merged
SimonCropp merged 3 commits into
mainfrom
fix-mac-repaint
Sep 23, 2026
Merged

SimonCropp merged 3 commits into
mainfrom
fix-mac-repaint

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

Fixes the macOS repaint item from todo.md. The binaries were rebuilt by build-native (#897, fast-forwarded into this branch).

  • Redraw only on change. Runtime.present marks the view for display only when the frame differs from the last one (Frame is now Equatable) or when a picture it names was rewritten, appeared or went (Renderer.picturesChanged, a stat per shown picture). The managed loop presents at 60 fps, and every present redrew the whole window, so an idle viewer kept a core busy. Resizes and splitter drags were already invalidated by AppKit and the view. A move to a display of another scale now invalidates too (viewDidChangeBackingProperties), because it changes the device pixels a scaled picture fills.
  • Cached scaled pictures. A picture drawn smaller than its own size is kept scaled to the device pixels it fills (Renderer.fitted), and a redraw copies it rather than resampling the source. The cache is dropped with the picture, so the existing eviction still bounds it. A picture drawn at or above its own size is drawn as before, which is every picture the capture baselines contain, so they're unaffected.

Not measured: there's no Mac here, so CI compiling the Swift and running the macOS pixel tests is the verification. Watching Activity Monitor on an idle viewer before and after would show the effect.

Only native/swift and todo.md change. The Windows image perf item, which #896 fixes, is still listed in this branch's todo.md and will merge cleanly beside it.

SimonCropp and others added 2 commits September 23, 2026 21:06
… pictures

- present marks the view for display only when the frame differs from the last
  one (Frame is now Equatable) or a picture it names was rewritten, appeared or
  went (Renderer.picturesChanged). The managed loop presents at 60 fps, and the
  whole window was redrawn on every one of them. Resizes, splitter drags and
  backing scale changes are invalidated as they happen.
- A picture scaled down is kept at the device pixels it fills
  (Renderer.fitted), so a redraw copies it rather than resampling the source.
  A picture drawn at or above its own size is drawn as before, which leaves the
  capture baselines as they are.
@SimonCropp SimonCropp added this to the 20.5.0 milestone Sep 23, 2026
@SimonCropp
SimonCropp merged commit 9bb1d41 into main Sep 23, 2026
11 checks passed
@SimonCropp
SimonCropp deleted the fix-mac-repaint branch September 23, 2026 11:15
This was referenced Sep 23, 2026
This was referenced Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant